/**
 * 
 */
package com.woniuxy.handler;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.pojo.Discount;
import com.woniuxy.service.DiscountService;

import lombok.Data;

/**
 * @author Fz
 * @date 2019年8月6日 下午3:54:33
 * @param 
 * @return
 */

@RestController
@RequestMapping("/discount")
@Data
public class DiscountHandler {
	@Resource
	private DiscountService discountService;
	
	@RequestMapping("/showall")
	public List<Discount> showAll(){
		return discountService.getAllD();
	}
	
	@RequestMapping("/addD")
	public String addD(Discount discount){
		if(discountService.addD(discount) > 0){
			return "添加成功";
		}else{
			return "添加失败";
		}
	}
	
	@RequestMapping("/delD")
	public String delD(String did){
		if(discountService.delD(did) > 0){
			return "删除成功";
		}else{
			return "删除失败";
		}
	}
	
	@RequestMapping("/update")
	public String updateD(Discount discount){
		if(discountService.updateD(discount) > 0){
			return "修改成功";
		}else{
			return "修改失败";
		}
	}
	
	@RequestMapping("/select")
	public List<Discount> selDiscount(String message){
		return discountService.selD(message);
	}
}
